made magic, now I can use this everywhere
made iterative max subarray function