add error handling, change api a little