refactored structure and fixed some rules