Added Documentation and added logic errors