I guess your solution is right.It is done here in the same way.
64.3k questions
77.9k answers
244k comments
80.0k users