general fibonacci implmenetation