change problem 2 answer to be programmatic