converting return type to scala 'List'
updating
Fixed 'trim' inefficiency by removing it