Rewrite & refactor