Refined the cost calculation a little, fixed error

Fixed a small syntax error. Made cost into an int after the changes are
applied.