Refactored to accept user inputs