Tried to put it in a function