rewriting most of the functions
Updating most functions