sample code cleaned a little, still not clean enough