replaced query with select