updated math code