reverted too using time sleep instead of a ticker because of the loop execution order