improved type safe queries