blindly add script code from stackoverflow