Reduce nesting and rename module