Modified shuffle algorithm