extracted method and covered with tests