Added error tracking at the top of the file