basic element implementation, some code refactoring