Added method from awesome StackOverflow answer! :)