still messy code, but good for snapshot