Integrated edit view code (slight modification of Jayeshs code)