cleaner implementation of script injection