rafactor the functions...