clean up, added more comments