fixed directory, added check for max N