final working version with hammered state