reimplementing ruby methods as an exercize