fixed formatting and added comments