Small change to sidebar render, moved code into separate function