this solution should be less db-intensive