cleaned up formatting and added comments