Ruby code
Added comments