Fixed semLoop() based on Brandon's suggestions