Refarctor querty in function for hard