the snippet I used to do that