Try block is reduced by distributing codes to separate functions