Change this to a while loop - also explicitly declare the return type for this function.