Refatoring to improve accuracy