Writing some functions myself