Minor refactoring and code style

Avoid one anonymous function and one more level of indentation :) The code looks simpler to me.
If you agree, please merge.