Refactored code for argument passing