Refactor program for more conciseness and readability