Fix missing end of if and dir check