Reimplemented layout of the page, added some logics