Move all the puts to a output method
Reduce complexity of database checks