Improved bounds for the Erdős-Rogers function