refactor element building