Add loop guards, optional and will be removed in build step