try to improve dir handling
porential fix to jpeg file regex