fix typo
minor changes
add query parameter support and reorganize code