Better function for depth