improve portability and preserve current switch