generalized the handling of elements so that id can also be handled