Added initial working version, need to add tests