Rewrote using OOP principles