changed conditions for boolean variables in lswithflags function