Partial refactor (objects instead of lambdas)