refactor a bit

make code cleaner