How are legal costs calculated?