fix logic issue