moved operations into functions