Working code. Actual results not same as expected