this code is also in search.js, maybe a mixin is more appropriate?