Refactor modal animation

Fix animation so that modal is persistent after one correct query.