Refactors transform prime

Splits up the tasks into functions