calculating stuff beforehand