Added the logic for the two functions