moved lines to make code more clear