updated for better multi support