Implemented a lot of functional