don't use distinct query for searching
javascript specs
some error handling & prevention