add worker logic and fix bugs