changed some function calls to references