Added Chad's code into main wpf application