New function for better z-index control