wrote all the code, now I need to fix an issue with the cost function