Solved problems 5 and 6. Updated functions file - rearranging and updating.