How is custody determined in a divorce case?