refactor code to better looking structure