Move the function initialize() upper

Move the function initialize() upper
Change if -> elif

Change if -> elif