Fixed bug and adds doc