fixed some formatting and added comments