adding subroutines and interrupt, lots of comments