Replace switch to avoid unnecessary computations