simplified and optimized 'execute' function