Fix getting filename
Fix path check