Added basicresult to remove some code duplication
Added lots of comments