refactor stuff to make it decent