Changed properties order
Moved serialize call ahead of switch statement