made code more object oriented