refined code, removed unnecessary transformations