introduced tmp_exec to sort out python memory error