Included the functionality into a function to allow customization of input and output