Added another condition with a loop

Added another condition with a loop