now it handles errors much better