tested old cas support fix and small code improvement

you don't need this PR.  but it is more clean.