Code based on a video tutorial I did.