Basics fonctions rewriten from scratch