complex implementation