added comments and QueryMap cast exception handling