Added fully functional code and updated README.md