refactor code + detect tablet