updated 'if' statements because of 'false positives' (!undefined is true)