Refactored code, updated README.md