Added some error tessting to be more sure of output