refactored scrambler control