refactor in separate modules, added transpose