Fix math bug