moved some stuff to functions