moved logic outside the class