function sorta working
updated function