updated data assignment based on @Seldaek suggestion