added reducing the length of data function