more organized, review code and add run time analysis