improved code in exec