factoring out most of the content