Fixed incorrect calculations