Cleanup diplicated code