reorganize code order more logically