Fixed a bug in references of elements