made it more optimal in memory usage