refactor blockdevices code