check function exists before declare