renamed variables and cleaned up