Is this how you solved the problem?