updated formatting and added/removed relevant comments