Directory transversal check refactored and fully working