added optional directory callback