Added error checking to methods.