refactor some old code in the cake