fix enum check, code clean-up