redone basically all code