fixed counting errors in fib main
improved loop logic