fixed bug in _prepare_version_query
fixing memorized-related bug