changed device detect functions and added some samples