Added function to set cost