cleaned up syntax, wrote unittests,