refactored InputBuffer