Corrected implementation