Still bugs to fix but the main idea is there