Extracted moving objects to own function