This change adds phi calculation from the database