1. Logic caculate