Fix ex 5 to work with empty input