fixed some "null" and "next" issues

tests were failing because I didn't properly fix all the branch checks