Main implementation