final version with two solutions