creating promise for index query