Separate main from handler implementation