fixed misplacement of module check (was before including config) and missing end