Made Code More Succinct

-Moved anonymous functions to named functions