FIX: may run into infinite loop.