Added dom manipulation code

Added some conditions when user manipulate dom element