Fixing null ref bug while querying profile data