Fix bugs & Refactring