Added some failchecking