removed extra singleton usage and simplified code