move check for existence of functions after their definition