Refracted some code and updated the readme