reorganize pieces and add more functionality