added safety checks on path creation (exists/isdir both)