added subs
added catch on exit