added in some more automation, but needs cleaning up at some point