alternative version with direct ports (loopNotWorking)