added algorithm directory parameter (not tested)