Splitting the mapper function to more readable methods