refactored module, now py3 compatible and utf aware-ish