duplication fix + refactoring

This fixes #3