make it more simple, move logic to one method