refactored
More fixes