Fixing small logic issue