make sure function exists before executing