reafactor almost almost done