Code for final year project.