factored the sleeping part out so I can move where it's called.