trying to improve db queries. unsuccessfully.