remove unused functions and refector