handle directories better