Fixed some logic in executeProcedure