added register functionality and added phpdocs