improved getAttribute Method