Implemented query expansion algorithm