Added Error Checking

Tracked the error down to some functions, no fix yet