Refactored plugin code and extracted js code to a spearate file