Fixed a bug and added doc strings