Updated function decleration gotchas

Use a named function instead of an anonymous function to simplify
debugging.