Added error gathering function