added dynamic device number allocation