he realized that there needed to be at least three floors in the castle just to reach the top of the cavern opening , but a fourth would allow him to leave a way for the dragons to get through that opening if necessary .