updated if-else and object declartion