some improvment according to scala
optim according to query
optim according to query