divided logic in two classes