Wrote this a while ago, thought someone could use it.