(NOT TESTED) almost complete