improving the performance by using bytearray