working serial implementation