replaced direct file manipulation with exec for slightly improved performance