added comments and logException methods