updated control module

fixed some error and rearrange the logic