add gauss function and refactoring and optimization