Rewrote with modularity