update: modify structure of nn function