bug fix and removing unused func