2-minute implementation based on a random code snippet I had laying around.