Improved theme detect