Added brackets to table and did some refactoring