extracted code to separate class