Fixed reference error when returning null