Reference code for Exercise A