fixed undefined functions and compile errors, still not working