refactored & optimized page toolbar code