Solve problem of extra space