Followed the solutions video to write this code