removed redundancy issues in code