Organize the code in a more logical way