new id code with all functions in one file

still working