fixes if statement

since this is not an array but a cursor, call .count() instead of .length