refactor variables and clean_up