bugfix and refactor from class to module