#4 Bugfix: improved implementation