Fixed Log and Calculate

also added some if statements in calculate