rubyfying the code