added createDevice function