Something like - https://gist.github.com/ehelms/6476483