improve the code

remove a few redundant IF