few changes to make code more readable