putting everything into functions