fix up bug caused by indentation, and make finding target element more reliable