Fully working with error checking.