added optional end index parameter for exec-instruction
updated execute-instruction to properly execute instructions up to the end-index
fixed execute-instruction function to work properly with an end index