minor code cleanup and a null check.