1. add source fail over; 2. code refactor