removed redundant checks and unused code