tidy into functions