Updated to fix bug, clean up, and add functionality