version with function for MySQL Database - not complete