improved clipping | code cleanup and refactoring