fixed warning and logic problem
Merge pull request #1186 from ZappoMan/bugfixes

fixed warning and logic problem