cleaned up code a whole lot