refactor operations as functions