Ruby code written for practice purpose