Fixed createWindow function