Modified (generate-fibonacci) function to use a function