added modules loader and functions switch_state and save