move more stuff to functions