some stuff refactored