using call instead of apply
removing unused function
renamed objects for clarity