Source code refactoring

This functionality also possibly opens up easy extension of new similar costs into the same functionality without copying and pasting code. 
this conflicts with our coding style guide; you're required to put braces around the conditional statement.