decent error handling, I hope this makes sense