Distance code

Please help me the class is going so slow