Fixed null return in tolocal function