add javascript check for deselecting