dummy bug corrected.
changed some logical conditions to be more stable.