removed debug code
added some functionality