Made sidebar code DRYer