fixed the order of variable initialization