Change action checking to be done in memory instead going to DB and do and aggregation query.