moved sidebar generation into a method
undid bad oops