refactor and move logic to timer class