manually duplicating #629