New attempt with ranges fixed