reworked to match the new api from sdl