Modified receiveObject() method, added casts and a switch-case