move stuff to a function