WIP: adding error handling functions