added directory handling