reformatted source and added comments