add comments, indent code to look cleaner