refactoctoring and cleanup