fixed checking for null/undefined