Refined the logic of capturing.