integrated shalom's work. not very cleanly done however