fixes issue #361 for autocomplete freetext

Please review and integrate, thanks!