added support for errors