refactor to ruby style