fixed all reset
fixed any internal reset
refactored
upgraded version with query fix