refactors josiah query.