updated with while