Slightly different implementation for updateenv