extracted the code to small classes