revised code for readability and updated README