attempt to fix looping bug