updated exec method to be more reliable on both windows and mac