turned it into functions