some steps towards refactor, currently not working though