complete functions and debug