fix bug in implementation