refined and printed out the answer