Added cmd line and http handler versions of code