Stable version with unit testing