cleaning up and commenting code