Refactor edit method, remove highlight method, optimize code to handle iframe