modularized sidebar logic