setup, dynamic programming finally working