Add missing $ and some debugging statements