Trying to fix logic Bug