fixes #1936
add additional check
wrap $where in conditional
Merge pull request #1937 from sumobi/master

fixes #1936