fixing and improving the sample script