Basic handler loop