update for second to last function, and last function - still not functioning