converted to ruby script