Fixing an error in slice generation