Added comments and changed is_done for increased efficiency