Added magic, some ref

still have a lot of work