Refactored code to use common.rs