First step for turning this into a library