rewrite of the sdl