rubocop style and some bug fix