Redesigned and added some function.