fixed broken build and added some exception handling