added bounds, some refactoring