Solution to problem 004