refactored, fixed transpose