fixing bug for returning data