replaced with while