completed the functions