Adding length of data being passed and removing redundant code