Added error handling
Made basic window work and made it work with error handling