added loop and elsif statement