fixed some active record queries