This is completely stolen from jneen's goodbot