Refactors psudo code