fixed glitches in code