Refactored to accept number input