moved singleton check to appropriate place