modify the space complexity