added default case
added user-agent and cleaned up a bit
made it more generic