Better use of objects and removed some unnecessary code