fixed sign error in search direction calculation