2nd iteration of code

re-worked functionality.