most of functions there. Just need to remove most bugs