added costFunction and sigmoid