ns pretty
added top level function call and refactoring for generic funcs