fixed if else bug. DO NOT USE PREVIOUS VERSION