Trying to reduce duplicated code a little

https://github.com/kfgodel/diamond/issues/15