changed handler structs to factory functions