Fixed function being undefined