Fixed code for finding length of domain