implement master detail