rework the overlay code