I writed the functions for the assignment