adjusted variable names for consistency and removed redundant code