Calculate base in a separate function