Refactor code and set active line