add APIs, enhanced error handling