added exercise 2 + finished cost function 1