Update functions to complete programming assignment 2