Fix for Issue #23

Added the check of getCategories to the buildquery..