first version of scala completion function