Changed mysql function