added ui and refactor code