refactored goto style loop in hopes it works on the server