Why was this calling the wrong function?