Problem with calculating width when switching between devices