must be cleaned
There are 2 functions, one with "SECURITY INVOKER" and the other with "SECURITY DEFINER". One is to be invoked by the final user and the other one only for the main function.