renamed variables and cleanup