Tidy up script a little