added export and configurable N