Added full functions for the programming assignment.