added documentation and prettyfied in general