Added function and changed some things