replaced null check for speed