refactor code to ruby2.0