Safety-critical in-vehicle applications require an accurate global time in order to coordinate their actions. Although Controller Area Network (CAN) is the most widely used in-vehicle communication bus, it does not support synchronized clocks. Hence, the realization of clock synchronization on CAN is highly relevant. This paper develops two new ideas for the clock synchronization on CAN. The first contribution is a new software-based algorithm based on periodic reference messages. Different from existing algorithms, the proposed algorithm enables the use of timestamps that are taken close to the reference message transmission hence improves the clock accuracy. The second contribution of the paper is an original method for correcting clocks between reference messages. In particular, the proposed algorithm updates local clocks based on the bit timing on the CAN bus. Results from simulation experiments show an improvement of about 60% in the clock precision.