feat: add better error handling, bug fixes