Refactor so that modal can be closed by overlay