Moved sidebar contoller logic to link function