bug fix and optimization of sidebar