implementation of the functions