add dismiss block, refactored a little