added bias term; fixed errors;