using hasValue instead of size