rearrange semaphores