Finalized code for submission