refactored code. updated readme.