altered search.js, added comments and structured it