fixed bugs in createData(),sql query, and other initialisations