ruby rebuild logic fix