replaced getclass with instanceof