result var moved to correct scope