include output
refactoring and handling for out of bound stuff