add floor and organize code