added funtionality to protect from wrong user input,and test to that end