Basic functionality working

Still need to work on corner cases