Cleaned up function definition

Also added named functions. Pretty simple considering it's just
anonymous functions.