implements and fixes #268