Exrtracted code into 3 methods