update code with latest schematic version
improve error handling