results cleaning then querying working using javascript promises