Correctly implement prepare and execute