improvements on script