Fixes generating algorithm