finished ruby code