fixing intervals, line cleaning and refactoring