using loop and condition