changed code for dynamic elements