bugfix, minor refactor