implemented depth based sorting so stuff is drawn back to front accordingly