Replaced mysql function calls