Updated If else and loop