Please, move this anonymos function to a named one out of the main one. This also applies for the one ten lines below. We should use functions as small in lines and simple as possible.