Working version of localNBNN