Modify ruby code according to comments