bug fix and runable version