abstracting into functions