fixed formatting and added more comments