construct keys inplace, lets optimize later