remove redundant checks and add comments