Updated to clean up code and  remove unnecesary confusing lines