Refactored to be dynamic based on inputs.