fix error handling and annotations bug