edited comments and code layout to make it more readable