added automatic filepath detection