parseElement function is performance optimized. Documentation is added.