fixed minor inconsistencies and passing by reference