Move transformation into its own function

Signed-off-by: Ian Macalinao <me@ian.pw>