Added else-if instead of two ifs