comments and some error checking
2 more tests passed
added error flag
few more tests passed