consolidated code to increase readability