Added functions for the assignment2