Changed code formatting and added peak memory use