better api and error message.