fix messages, clean & refactor code