completed script to tidy data