fix(logic): Fixed issue with throwing the error outside of the if statement