fix and remove unnecessary codes