Trying reverse logic for problem 5