repaired element distribution code... should be ready for actual development