Improve code readability of lab 3 solution