Updated remove to handle directories