Fixed bug with device count