Moved ship update code to its own function