editing old code for better readability