Implemented minimal solution to the problem