Wrapped up GST code written by Jacob, begining Error management