Add a rather complicated implementation