TODO: break code into modules, add unit testing