tried to separate logic