added slightly hacky error callback