events functions implemented when show and hide modal