Fix to handle while loops as well.