Revised implementation