refactored typed queries - initial version