Updated reference to objects

Replaced switch statement with if statements that reference cases Object. Tested and it works.