height and widht detection; demo code apart