Cleaned up code, added submethods, removed extraneous variables