replace nil checks with assert