final version of MySQL script