updated remove extraneous data function to remove bug