reordered code
fix for #435