function is not defined when in