Refactor transform functions