Added scope pattern for table joins