Finalized command handler for Query Command, also added comments.