organize code to be slightly less hackish