Added error check to last files