Why is my return not calculating correctly?