fixed database error after activation
db query optimization