improve checkbox logic