cleaned up code, made easier to read