updated conditional code and removed redundant code