Completed code for two functions