Changed elif to if in function