Fix bug in implementation