modularizing Serp code