Refactoring with applicative style