Fixed null reference bug