changed function to classes instead of lambdas