Final annotated code for prototype