improved code and reused methods