remove useless checks and simplify some code