further code cleanup, codes in controllers moved to link