implemented fib function