Added the handle and handleDevice functions