improve js handling for the collapse/expand