Move similar query in words controller into a private method