fixing parentElement code