Re-factored code (same as the zipped folder I had sent earlier via fb). Feel free to make changes on this branch