translated to ruby