Working code with SDL output