copied file from upstream master