small cleanup of some loops