refactoing code a whole bunch and sort of starting from scratch