replaced named_scope with scope, and updated version