function to get bg depth