refactored code and added to readme