Start of finalized code