refactor result_handler.rb