condensed some things into functions