functions implementation