improve sign handling
refactoring simplification