Code cleanup

easier to read and follow now