fixed data directory, less duplicate code + tabbed indentation