switched to references instead of pointers whereever possible