completed functions for the programming assignment