Implementing the two functions