Simplifying tabs creation

This pull requests fixes the "count" thing in the loops and also removes the need of declaring the tabs and closing them.