Fix incorrect calculations