did even more refactoring with the suggestions of sampsyo. added documentation page