Moved Script to script file from view