added error checking in window initilization