added test funciton and user input validation