wrote helper function for repetative stuff