implement the basic functions but didn't debug yet