add generic implementation, case tests