Improved logical flow through functions